]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-theme-node: Add support for -st-icon-style property
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Nov 2014 14:53:36 +0000 (14:53 +0000)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Nov 2014 17:13:03 +0000 (18:13 +0100)
GTK+ added support for a -gtk-icon-style property in themes to
enforce a particular icon style. Do the same for shell themes
with an -st-icon-style property, with the same set of possible
values as the GTK+ variant:
  'requested' - use symbolic or fullcolor icon depending on the
                icon name (default)
  'regular'   - enforce fullcolor icons
  'symbolic'  - enforce symbolic icons

https://bugzilla.gnome.org/show_bug.cgi?id=740447

src/st/st-texture-cache.c
src/st/st-theme-node.c
src/st/st-theme-node.h

index 09addbe46eca0c36fe301dd45bfc22041a4d1833..ccee96cb85e868b22c03cdf0c666d1f100c5af8e 100644 (file)
@@ -842,16 +842,25 @@ st_texture_cache_load_gicon (StTextureCache    *cache,
   GtkIconInfo *info;
   StTextureCachePolicy policy;
   StIconColors *colors = NULL;
+  StIconStyle icon_style = ST_ICON_STYLE_REQUESTED;
   GtkIconLookupFlags lookup_flags;
 
   if (theme_node)
-    colors = st_theme_node_get_icon_colors (theme_node);
+    {
+      colors = st_theme_node_get_icon_colors (theme_node);
+      icon_style = st_theme_node_get_icon_style (theme_node);
+    }
 
   /* Do theme lookups in the main thread to avoid thread-unsafety */
   theme = cache->priv->icon_theme;
 
   lookup_flags = GTK_ICON_LOOKUP_USE_BUILTIN;
 
+  if (icon_style == ST_ICON_STYLE_REGULAR)
+    lookup_flags |= GTK_ICON_LOOKUP_FORCE_REGULAR;
+  else if (icon_style == ST_ICON_STYLE_SYMBOLIC)
+    lookup_flags |= GTK_ICON_LOOKUP_FORCE_SYMBOLIC;
+
   if (clutter_get_default_text_direction () == CLUTTER_TEXT_DIRECTION_RTL)
     lookup_flags |= GTK_ICON_LOOKUP_DIR_RTL;
   else
@@ -871,8 +880,8 @@ st_texture_cache_load_gicon (StTextureCache    *cache,
   if (colors)
     {
       /* This raises some doubts about the practice of using string keys */
-      key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
-                             gicon_string, size, scale,
+      key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,style=%d,colors=%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x,%2x%2x%2x%2x",
+                             gicon_string, size, scale, icon_style,
                              colors->foreground.red, colors->foreground.blue, colors->foreground.green, colors->foreground.alpha,
                              colors->warning.red, colors->warning.blue, colors->warning.green, colors->warning.alpha,
                              colors->error.red, colors->error.blue, colors->error.green, colors->error.alpha,
@@ -880,8 +889,8 @@ st_texture_cache_load_gicon (StTextureCache    *cache,
     }
   else
     {
-      key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d",
-                             gicon_string, size, scale);
+      key = g_strdup_printf (CACHE_PREFIX_ICON "%s,size=%d,scale=%d,style=%d",
+                             gicon_string, size, scale, icon_style);
     }
   g_free (gicon_string);
 
index c6c6e8917377b87fe27fbfa1f54c3c40b966e80f..9aedc3ba1584a3fd7d3bcb3afbef32e4b57ba28c 100644 (file)
@@ -2392,6 +2392,48 @@ st_theme_node_get_transition_duration (StThemeNode *node)
   return st_slow_down_factor * node->transition_duration;
 }
 
+StIconStyle
+st_theme_node_get_icon_style (StThemeNode *node)
+{
+  int i;
+
+  ensure_properties (node);
+
+  for (i = node->n_properties - 1; i >= 0; i--)
+    {
+      CRDeclaration *decl = node->properties[i];
+
+      if (strcmp (decl->property->stryng->str, "-st-icon-style") == 0)
+        {
+          CRTerm *term;
+
+          for (term = decl->value; term; term = term->next)
+            {
+              if (term->type != TERM_IDENT)
+                goto next_decl;
+
+              if (strcmp (term->content.str->stryng->str, "requested") == 0)
+                return ST_ICON_STYLE_REQUESTED;
+              else if (strcmp (term->content.str->stryng->str, "regular") == 0)
+                return ST_ICON_STYLE_REGULAR;
+              else if (strcmp (term->content.str->stryng->str, "symbolic") == 0)
+                return ST_ICON_STYLE_SYMBOLIC;
+              else
+                g_warning ("Unknown -st-icon-style \"%s\"",
+                           term->content.str->stryng->str);
+            }
+        }
+
+    next_decl:
+      ;
+    }
+
+  if (node->parent_node)
+    return st_theme_node_get_icon_style (node->parent_node);
+
+  return ST_ICON_STYLE_REQUESTED;
+}
+
 StTextDecoration
 st_theme_node_get_text_decoration (StThemeNode *node)
 {
index a193f5ae75ee297c140e1fbc797da15c543df545..0a5edf9124190a403934617fa52ce32fafbf6cca 100644 (file)
@@ -94,6 +94,12 @@ typedef enum {
   ST_GRADIENT_RADIAL
 } StGradientType;
 
+typedef enum {
+  ST_ICON_STYLE_REQUESTED,
+  ST_ICON_STYLE_REGULAR,
+  ST_ICON_STYLE_SYMBOLIC
+} StIconStyle;
+
 typedef struct _StThemeNodePaintState StThemeNodePaintState;
 
 struct _StThemeNodePaintState {
@@ -220,6 +226,8 @@ int    st_theme_node_get_max_height    (StThemeNode  *node);
 
 int    st_theme_node_get_transition_duration (StThemeNode *node);
 
+StIconStyle st_theme_node_get_icon_style (StThemeNode *node);
+
 StTextDecoration st_theme_node_get_text_decoration (StThemeNode *node);
 
 StTextAlign st_theme_node_get_text_align (StThemeNode *node);